package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/param")
public class GetParamServlet extends HttpServlet{

	/*
	 * 地址栏：http://localhost:8080/20230703_filter_listener_upload/param?name=lisi
	 * 
	 * <form action="http://localhost:8080/20230703_filter_listener_upload/param" method="get">
           <input type="text" name="name" />
           <input type="submit" value="提交"/>
       </form>
	 */
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String name = req.getParameter("name");
		System.out.println(name);
	}
	/*
	 * 
	 * <form action="http://localhost:8080/20230703_filter_listener_upload/param" 
	        method="post">
           <input type="text" name="name" />
           <input type="submit" value="提交"/>
    	</form>
	 */
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String name = req.getParameter("name");
		System.out.println(name);
	}
}
